package com.sm.healthy.ui.dialog

import android.app.Dialog
import android.content.Context
import android.os.Bundle
import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
import android.view.WindowManager
import android.widget.ImageView
import android.widget.TextView
import com.sm.healthy.R
import com.sm.healthy.utils.DensityUtil

class BloodOxygenDialog1(context: Context, themeResId: Int) : Dialog(context, themeResId) {
    private val TAG = BloodOxygenDialog1::class.java.simpleName

    var mContext: Context = context

    var img_right: ImageView? = null
    var tv_close: TextView? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setCanceledOnTouchOutside(true)
        window?.setGravity(Gravity.BOTTOM)
        window?.setWindowAnimations(R.style.BottomSelectAnimation)

        var view: View = LayoutInflater.from(mContext).inflate(R.layout.dialog_content_circle, null)
        initView(view)
        setContentView(view)
        initListener()
    }

    private fun initListener() {
        tv_close?.setOnClickListener {
            dismiss()
        }
        img_right?.setOnClickListener {

            val bloodOxygenDialog2 = BloodOxygenDialog2(mContext, R.style.BottomDialog)
            bloodOxygenDialog2.show()
        }
    }


    private fun initView(view: View) {
        img_right = view.findViewById(R.id.img_right)
        tv_close = view.findViewById(R.id.tv_close)
    }

    override fun show() {
        super.show()

        val layoutParams = window!!.attributes
        layoutParams.gravity = Gravity.CENTER
        layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT
        layoutParams.height = WindowManager.LayoutParams.MATCH_PARENT
        window!!.decorView.setPadding(
            0,
            0,
            0,
            0
        )
        window!!.attributes = layoutParams
    }
}